package com.mall.controller;

import com.mall.autoconfig.temple.OssTemplate;
import com.mall.commons.common.CommonResult;
import com.mall.service.AliyunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/aliyun")
public class AliyunController {

    @Autowired
    private AliyunService aliyunService;

    /**
     * 图片上传
     * @param photoFile
     * @return
     * @throws IOException
     */
    @PostMapping("/oss/upload")
    public CommonResult upload(MultipartFile photoFile) throws IOException {

      Map map = aliyunService.upload(photoFile);

        return CommonResult.success(map);
    }
}
